﻿namespace Example.Configuration
{
    using System.Configuration;
    using System.Xml;

    using Xunit;

    public class CustomConfigurationFacts
    {
        [Fact]
        public void ctor()
        {
            Assert.NotNull(new CustomConfiguration());
        }

        [Fact]
        public void is_IConfigurationSectionHandler()
        {
            Assert.IsAssignableFrom<IConfigurationSectionHandler>(new CustomConfiguration());
        }

        [Fact]
        public void op_Create_object_object_XmlNode()
        {
            var xml = new XmlDocument();
            xml.LoadXml("<custom setting=\"test\"/>");

            var expected = new CustomSettings("test");
            var actual = new CustomConfiguration().Create(null, null, xml.DocumentElement) as CustomSettings;

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void op_Create_object_object_XmlNodeEmpty()
        {
            var xml = new XmlDocument();
            xml.LoadXml("<custom />");

            var expected = new CustomSettings();
            var actual = new CustomConfiguration().Create(null, null, xml.DocumentElement) as CustomSettings;

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void op_Create_object_object_XmlNodeNull()
        {
            var obj = new CustomConfiguration().Create(null, null, null) as CustomSettings;

            Assert.Null(obj);
        }

        [Fact]
        public void op_Settings()
        {
            // no test
        }

        [Fact]
        public void op_Settings_string()
        {
            // no test
        }
    }
}